package io.geekidea.boot.shop.service.business.business;

import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import io.geekidea.boot.shop.dto.OrderMainDto;
import io.geekidea.boot.shop.service.business.api.OrderBusinessService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Date: 2024/11/1
 */
@Service
@Slf4j
@AllArgsConstructor
public class OrderBusinessServiceImpl implements OrderBusinessService {

    private WxPayService wxPayService;

    @Override
    public void createOrder(OrderMainDto orderMainDto) {
        //1.保存订单头表和明细表，状态未待付款
        //2.扣商品库存
        //3.保存出入库记录表

        //4.创建微信订单

    }


    private void createWxOrder() {
        WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
        try {
            request.setBody("");
            //订单号
            request.setOutTradeNo("");
            //总价格
            request.setTotalFee(1);
            //终端IP.
            request.setSpbillCreateIp("");
            //回调地址
            request.setNotifyUrl("");
            wxPayService.createOrder(request);
        } catch (WxPayException e) {
            throw new RuntimeException(e);
        }
    }
}
